
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>适合手机、pad等移动终端的tab响应式切换效果</title>
<link rel="stylesheet" href="css/tab.css">
</head>
<body>
<!-- 代码部分begin -->
<div class="wrap">
    <div class="tabs">
        <a href="#" hidefocus="true" class="active">手机端</a>
        <a href="#" hidefocus="true">选项卡</a>
        <a href="#" hidefocus="true">切换效果</a>
    </div>
    <div class="swiper-container">
        <div class="swiper-wrapper">
        <div class="swiper-slide">
           <div class="content-slide">
              tab内容一
          </div>
          </div>
        <div class="swiper-slide">
            <div class="content-slide">
             tab内容二
            </div>
          </div>
        <div class="swiper-slide">
            <div class="content-slide">
             tab内容三
            </div>
          </div>
      </div>
   </div>
</div>
<script src="jquery.min.js"></script>
<script src="idangerous.swiper.min.js"></script>
<script>
var tabsSwiper = new Swiper('.swiper-container',{
	speed:500,
	onSlideChangeStart: function(){
		$(".tabs .active").removeClass('active');
		$(".tabs a").eq(tabsSwiper.activeIndex).addClass('active');
	}
});

$(".tabs a").on('touchstart mousedown',function(e){
	e.preventDefault()
	$(".tabs .active").removeClass('active');
	$(this).addClass('active');
	tabsSwiper.slideTo($(this).index());
});

$(".tabs a").click(function(e){
	e.preventDefault();
});
</script>
<!-- 代码部分end -->
</body>
</html>
